﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using DBUtility;//Please add references
namespace TierApplication
{
    /// <summary>
    /// 类T_OrderDetail。
    /// </summary>
    [Serializable]
    public partial class T_OrderDetail
    {
        public T_OrderDetail()
        { }
        #region Model
        private string _orderdetailid;
        private string _orderid;
        private string _porderdetailid;
        private string _psaledetailid;
        private string _relaid;
        private string _productid;
        private string _producttype;
        private string _productname;
        private string _productno;
        private string _batchno;
        private decimal? _plnquantity = 0M;
        private decimal? _shpquantity = 0M;
        private decimal? _actquantity = 0M;
        private decimal? _bckquantity = 0M;
        private decimal? _unitpricem = 0M;
        private decimal? _unitprice = 0M;
        private decimal? _discount = 0M;
        private decimal? _productlpricem;
        private decimal? _productlprice;
        private decimal? _hourlypricem;
        private decimal? _hourlyprice;
        private decimal? _sumpricem;
        private decimal? _sumprice;
        private decimal? _point = 0M;
        private string _remark;
        private DateTime? _createdate = DateTime.Now;
        private string _createuser = "getdate";
        private string _depotarea;
        private string _usefullifetype;
        private DateTime? _usefullife;
        private string _baseproductplace;
        /// <summary>
        /// 
        /// </summary>
        public string OrderDetailID
        {
            set { _orderdetailid = value; }
            get { return _orderdetailid; }
        }
        /// <summary>
        /// 
        /// </summary>
        public string OrderID
        {
            set { _orderid = value; }
            get { return _orderid; }
        }
        /// <summary>
        /// 
        /// </summary>
        public string POrderDetailID
        {
            set { _porderdetailid = value; }
            get { return _porderdetailid; }
        }
        /// <summary>
        /// 
        /// </summary>
        public string PSaleDetailID
        {
            set { _psaledetailid = value; }
            get { return _psaledetailid; }
        }
        /// <summary>
        /// 
        /// </summary>
        public string RelaID
        {
            set { _relaid = value; }
            get { return _relaid; }
        }
        /// <summary>
        /// 
        /// </summary>
        public string ProductID
        {
            set { _productid = value; }
            get { return _productid; }
        }
        /// <summary>
        /// 
        /// </summary>
        public string ProductType
        {
            set { _producttype = value; }
            get { return _producttype; }
        }
        /// <summary>
        /// 
        /// </summary>
        public string ProductName
        {
            set { _productname = value; }
            get { return _productname; }
        }
        /// <summary>
        /// 
        /// </summary>
        public string ProductNo
        {
            set { _productno = value; }
            get { return _productno; }
        }
        /// <summary>
        /// 
        /// </summary>
        public string BatchNo
        {
            set { _batchno = value; }
            get { return _batchno; }
        }
        /// <summary>
        /// 计划数量
        /// </summary>
        public decimal? PlnQuantity
        {
            set { _plnquantity = value; }
            get { return _plnquantity; }
        }
        /// <summary>
        /// 发货数量
        /// </summary>
        public decimal? ShpQuantity
        {
            set { _shpquantity = value; }
            get { return _shpquantity; }
        }
        /// <summary>
        /// 实际数量
        /// </summary>
        public decimal? ActQuantity
        {
            set { _actquantity = value; }
            get { return _actquantity; }
        }
        /// <summary>
        /// 退货数量
        /// </summary>
        public decimal? BckQuantity
        {
            set { _bckquantity = value; }
            get { return _bckquantity; }
        }
        /// <summary>
        /// 
        /// </summary>
        public decimal? UnitPriceM
        {
            set { _unitpricem = value; }
            get { return _unitpricem; }
        }
        /// <summary>
        /// 
        /// </summary>
        public decimal? UnitPrice
        {
            set { _unitprice = value; }
            get { return _unitprice; }
        }
        /// <summary>
        /// 
        /// </summary>
        public decimal? Discount
        {
            set { _discount = value; }
            get { return _discount; }
        }
        /// <summary>
        /// 
        /// </summary>
        public decimal? ProductlPriceM
        {
            set { _productlpricem = value; }
            get { return _productlpricem; }
        }
        /// <summary>
        /// 
        /// </summary>
        public decimal? ProductlPrice
        {
            set { _productlprice = value; }
            get { return _productlprice; }
        }
        /// <summary>
        /// 
        /// </summary>
        public decimal? HourlyPriceM
        {
            set { _hourlypricem = value; }
            get { return _hourlypricem; }
        }
        /// <summary>
        /// 
        /// </summary>
        public decimal? HourlyPrice
        {
            set { _hourlyprice = value; }
            get { return _hourlyprice; }
        }
        /// <summary>
        /// 
        /// </summary>
        public decimal? SumPriceM
        {
            set { _sumpricem = value; }
            get { return _sumpricem; }
        }
        /// <summary>
        /// 
        /// </summary>
        public decimal? SumPrice
        {
            set { _sumprice = value; }
            get { return _sumprice; }
        }
        /// <summary>
        /// 
        /// </summary>
        public decimal? Point
        {
            set { _point = value; }
            get { return _point; }
        }
        /// <summary>
        /// 
        /// </summary>
        public string Remark
        {
            set { _remark = value; }
            get { return _remark; }
        }
        /// <summary>
        /// 
        /// </summary>
        public DateTime? CreateDate
        {
            set { _createdate = value; }
            get { return _createdate; }
        }
        /// <summary>
        /// 
        /// </summary>
        public string CreateUser
        {
            set { _createuser = value; }
            get { return _createuser; }
        }
        /// <summary>
        /// 
        /// </summary>
        public string DepotArea
        {
            set { _depotarea = value; }
            get { return _depotarea; }
        }
        /// <summary>
        /// 
        /// </summary>
        public string UsefulLifeType
        {
            set { _usefullifetype = value; }
            get { return _usefullifetype; }
        }
        /// <summary>
        /// 
        /// </summary>
        public DateTime? UsefulLife
        {
            set { _usefullife = value; }
            get { return _usefullife; }
        }
        /// <summary>
        /// 
        /// </summary>
        public string BaseProductPlace
        {
            set { _baseproductplace = value; }
            get { return _baseproductplace; }
        }
        #endregion Model


        #region  Method

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public T_OrderDetail(string OrderDetailID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select OrderDetailID,OrderID,POrderDetailID,PSaleDetailID,RelaID,ProductID,ProductType,ProductName,ProductNo,BatchNo,PlnQuantity,ShpQuantity,ActQuantity,BckQuantity,UnitPriceM,UnitPrice,Discount,ProductlPriceM,ProductlPrice,HourlyPriceM,HourlyPrice,SumPriceM,SumPrice,Point,Remark,CreateDate,CreateUser,DepotArea,UsefulLifeType,UsefulLife,BaseProductPlace ");
            strSql.Append(" FROM [T_OrderDetail] ");
            strSql.Append(" where OrderDetailID=@OrderDetailID ");
            SqlParameter[] parameters = {
					new SqlParameter("@OrderDetailID", SqlDbType.VarChar,-1)};
            parameters[0].Value = OrderDetailID;

            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["OrderDetailID"] != null)
                {
                    this.OrderDetailID = ds.Tables[0].Rows[0]["OrderDetailID"].ToString();
                }
                if (ds.Tables[0].Rows[0]["OrderID"] != null)
                {
                    this.OrderID = ds.Tables[0].Rows[0]["OrderID"].ToString();
                }
                if (ds.Tables[0].Rows[0]["POrderDetailID"] != null)
                {
                    this.POrderDetailID = ds.Tables[0].Rows[0]["POrderDetailID"].ToString();
                }
                if (ds.Tables[0].Rows[0]["PSaleDetailID"] != null)
                {
                    this.PSaleDetailID = ds.Tables[0].Rows[0]["PSaleDetailID"].ToString();
                }
                if (ds.Tables[0].Rows[0]["RelaID"] != null)
                {
                    this.RelaID = ds.Tables[0].Rows[0]["RelaID"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ProductID"] != null)
                {
                    this.ProductID = ds.Tables[0].Rows[0]["ProductID"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ProductType"] != null)
                {
                    this.ProductType = ds.Tables[0].Rows[0]["ProductType"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ProductName"] != null)
                {
                    this.ProductName = ds.Tables[0].Rows[0]["ProductName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ProductNo"] != null)
                {
                    this.ProductNo = ds.Tables[0].Rows[0]["ProductNo"].ToString();
                }
                if (ds.Tables[0].Rows[0]["BatchNo"] != null)
                {
                    this.BatchNo = ds.Tables[0].Rows[0]["BatchNo"].ToString();
                }
                if (ds.Tables[0].Rows[0]["PlnQuantity"] != null && ds.Tables[0].Rows[0]["PlnQuantity"].ToString() != "")
                {
                    this.PlnQuantity = decimal.Parse(ds.Tables[0].Rows[0]["PlnQuantity"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ShpQuantity"] != null && ds.Tables[0].Rows[0]["ShpQuantity"].ToString() != "")
                {
                    this.ShpQuantity = decimal.Parse(ds.Tables[0].Rows[0]["ShpQuantity"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ActQuantity"] != null && ds.Tables[0].Rows[0]["ActQuantity"].ToString() != "")
                {
                    this.ActQuantity = decimal.Parse(ds.Tables[0].Rows[0]["ActQuantity"].ToString());
                }
                if (ds.Tables[0].Rows[0]["BckQuantity"] != null && ds.Tables[0].Rows[0]["BckQuantity"].ToString() != "")
                {
                    this.BckQuantity = decimal.Parse(ds.Tables[0].Rows[0]["BckQuantity"].ToString());
                }
                if (ds.Tables[0].Rows[0]["UnitPriceM"] != null && ds.Tables[0].Rows[0]["UnitPriceM"].ToString() != "")
                {
                    this.UnitPriceM = decimal.Parse(ds.Tables[0].Rows[0]["UnitPriceM"].ToString());
                }
                if (ds.Tables[0].Rows[0]["UnitPrice"] != null && ds.Tables[0].Rows[0]["UnitPrice"].ToString() != "")
                {
                    this.UnitPrice = decimal.Parse(ds.Tables[0].Rows[0]["UnitPrice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Discount"] != null && ds.Tables[0].Rows[0]["Discount"].ToString() != "")
                {
                    this.Discount = decimal.Parse(ds.Tables[0].Rows[0]["Discount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ProductlPriceM"] != null && ds.Tables[0].Rows[0]["ProductlPriceM"].ToString() != "")
                {
                    this.ProductlPriceM = decimal.Parse(ds.Tables[0].Rows[0]["ProductlPriceM"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ProductlPrice"] != null && ds.Tables[0].Rows[0]["ProductlPrice"].ToString() != "")
                {
                    this.ProductlPrice = decimal.Parse(ds.Tables[0].Rows[0]["ProductlPrice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["HourlyPriceM"] != null && ds.Tables[0].Rows[0]["HourlyPriceM"].ToString() != "")
                {
                    this.HourlyPriceM = decimal.Parse(ds.Tables[0].Rows[0]["HourlyPriceM"].ToString());
                }
                if (ds.Tables[0].Rows[0]["HourlyPrice"] != null && ds.Tables[0].Rows[0]["HourlyPrice"].ToString() != "")
                {
                    this.HourlyPrice = decimal.Parse(ds.Tables[0].Rows[0]["HourlyPrice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SumPriceM"] != null && ds.Tables[0].Rows[0]["SumPriceM"].ToString() != "")
                {
                    this.SumPriceM = decimal.Parse(ds.Tables[0].Rows[0]["SumPriceM"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SumPrice"] != null && ds.Tables[0].Rows[0]["SumPrice"].ToString() != "")
                {
                    this.SumPrice = decimal.Parse(ds.Tables[0].Rows[0]["SumPrice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Point"] != null && ds.Tables[0].Rows[0]["Point"].ToString() != "")
                {
                    this.Point = decimal.Parse(ds.Tables[0].Rows[0]["Point"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Remark"] != null)
                {
                    this.Remark = ds.Tables[0].Rows[0]["Remark"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CreateDate"] != null && ds.Tables[0].Rows[0]["CreateDate"].ToString() != "")
                {
                    this.CreateDate = DateTime.Parse(ds.Tables[0].Rows[0]["CreateDate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CreateUser"] != null)
                {
                    this.CreateUser = ds.Tables[0].Rows[0]["CreateUser"].ToString();
                }
                if (ds.Tables[0].Rows[0]["DepotArea"] != null)
                {
                    this.DepotArea = ds.Tables[0].Rows[0]["DepotArea"].ToString();
                }
                if (ds.Tables[0].Rows[0]["UsefulLifeType"] != null)
                {
                    this.UsefulLifeType = ds.Tables[0].Rows[0]["UsefulLifeType"].ToString();
                }
                if (ds.Tables[0].Rows[0]["UsefulLife"] != null && ds.Tables[0].Rows[0]["UsefulLife"].ToString() != "")
                {
                    this.UsefulLife = DateTime.Parse(ds.Tables[0].Rows[0]["UsefulLife"].ToString());
                }
                if (ds.Tables[0].Rows[0]["BaseProductPlace"] != null)
                {
                    this.BaseProductPlace = ds.Tables[0].Rows[0]["BaseProductPlace"].ToString();
                }
            }
        }

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(string OrderDetailID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from [T_OrderDetail]");
            strSql.Append(" where OrderDetailID=@OrderDetailID ");

            SqlParameter[] parameters = {
					new SqlParameter("@OrderDetailID", SqlDbType.VarChar,-1)};
            parameters[0].Value = OrderDetailID;

            return DbHelperSQL.Exists(strSql.ToString(), parameters);
        }


        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into [T_OrderDetail] (");
            strSql.Append("OrderDetailID,OrderID,POrderDetailID,PSaleDetailID,RelaID,ProductID,ProductType,ProductName,ProductNo,BatchNo,PlnQuantity,ShpQuantity,ActQuantity,BckQuantity,UnitPriceM,UnitPrice,Discount,ProductlPriceM,ProductlPrice,HourlyPriceM,HourlyPrice,SumPriceM,SumPrice,Point,Remark,CreateDate,CreateUser,DepotArea,UsefulLifeType,UsefulLife,BaseProductPlace)");
            strSql.Append(" values (");
            strSql.Append("@OrderDetailID,@OrderID,@POrderDetailID,@PSaleDetailID,@RelaID,@ProductID,@ProductType,@ProductName,@ProductNo,@BatchNo,@PlnQuantity,@ShpQuantity,@ActQuantity,@BckQuantity,@UnitPriceM,@UnitPrice,@Discount,@ProductlPriceM,@ProductlPrice,@HourlyPriceM,@HourlyPrice,@SumPriceM,@SumPrice,@Point,@Remark,@CreateDate,@CreateUser,@DepotArea,@UsefulLifeType,@UsefulLife,@BaseProductPlace)");
            SqlParameter[] parameters = {
					new SqlParameter("@OrderDetailID", SqlDbType.VarChar,10),
					new SqlParameter("@OrderID", SqlDbType.VarChar,10),
					new SqlParameter("@POrderDetailID", SqlDbType.VarChar,10),
					new SqlParameter("@PSaleDetailID", SqlDbType.VarChar,10),
					new SqlParameter("@RelaID", SqlDbType.VarChar,10),
					new SqlParameter("@ProductID", SqlDbType.VarChar,10),
					new SqlParameter("@ProductType", SqlDbType.VarChar,50),
					new SqlParameter("@ProductName", SqlDbType.VarChar,100),
					new SqlParameter("@ProductNo", SqlDbType.VarChar,100),
					new SqlParameter("@BatchNo", SqlDbType.VarChar,20),
					new SqlParameter("@PlnQuantity", SqlDbType.Decimal,9),
					new SqlParameter("@ShpQuantity", SqlDbType.Decimal,9),
					new SqlParameter("@ActQuantity", SqlDbType.Decimal,9),
					new SqlParameter("@BckQuantity", SqlDbType.Decimal,9),
					new SqlParameter("@UnitPriceM", SqlDbType.Decimal,9),
					new SqlParameter("@UnitPrice", SqlDbType.Decimal,9),
					new SqlParameter("@Discount", SqlDbType.Decimal,9),
					new SqlParameter("@ProductlPriceM", SqlDbType.Decimal,9),
					new SqlParameter("@ProductlPrice", SqlDbType.Decimal,9),
					new SqlParameter("@HourlyPriceM", SqlDbType.Decimal,9),
					new SqlParameter("@HourlyPrice", SqlDbType.Decimal,9),
					new SqlParameter("@SumPriceM", SqlDbType.Decimal,9),
					new SqlParameter("@SumPrice", SqlDbType.Decimal,9),
					new SqlParameter("@Point", SqlDbType.Decimal,9),
					new SqlParameter("@Remark", SqlDbType.VarChar,50),
					new SqlParameter("@CreateDate", SqlDbType.DateTime),
					new SqlParameter("@CreateUser", SqlDbType.VarChar,10),
					new SqlParameter("@DepotArea", SqlDbType.VarChar,20),
					new SqlParameter("@UsefulLifeType", SqlDbType.VarChar,10),
					new SqlParameter("@UsefulLife", SqlDbType.DateTime),
					new SqlParameter("@BaseProductPlace", SqlDbType.VarChar,100)};
            parameters[0].Value = OrderDetailID;
            parameters[1].Value = OrderID;
            parameters[2].Value = POrderDetailID;
            parameters[3].Value = PSaleDetailID;
            parameters[4].Value = RelaID;
            parameters[5].Value = ProductID;
            parameters[6].Value = ProductType;
            parameters[7].Value = ProductName;
            parameters[8].Value = ProductNo;
            parameters[9].Value = BatchNo;
            parameters[10].Value = PlnQuantity;
            parameters[11].Value = ShpQuantity;
            parameters[12].Value = ActQuantity;
            parameters[13].Value = BckQuantity;
            parameters[14].Value = UnitPriceM;
            parameters[15].Value = UnitPrice;
            parameters[16].Value = Discount;
            parameters[17].Value = ProductlPriceM;
            parameters[18].Value = ProductlPrice;
            parameters[19].Value = HourlyPriceM;
            parameters[20].Value = HourlyPrice;
            parameters[21].Value = SumPriceM;
            parameters[22].Value = SumPrice;
            parameters[23].Value = Point;
            parameters[24].Value = Remark;
            parameters[25].Value = CreateDate;
            parameters[26].Value = CreateUser;
            parameters[27].Value = DepotArea;
            parameters[28].Value = UsefulLifeType;
            parameters[29].Value = UsefulLife;
            parameters[30].Value = BaseProductPlace;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update [T_OrderDetail] set ");
            strSql.Append("OrderID=@OrderID,");
            strSql.Append("POrderDetailID=@POrderDetailID,");
            strSql.Append("PSaleDetailID=@PSaleDetailID,");
            strSql.Append("RelaID=@RelaID,");
            strSql.Append("ProductID=@ProductID,");
            strSql.Append("ProductType=@ProductType,");
            strSql.Append("ProductName=@ProductName,");
            strSql.Append("ProductNo=@ProductNo,");
            strSql.Append("BatchNo=@BatchNo,");
            strSql.Append("PlnQuantity=@PlnQuantity,");
            strSql.Append("ShpQuantity=@ShpQuantity,");
            strSql.Append("ActQuantity=@ActQuantity,");
            strSql.Append("BckQuantity=@BckQuantity,");
            strSql.Append("UnitPriceM=@UnitPriceM,");
            strSql.Append("UnitPrice=@UnitPrice,");
            strSql.Append("Discount=@Discount,");
            strSql.Append("ProductlPriceM=@ProductlPriceM,");
            strSql.Append("ProductlPrice=@ProductlPrice,");
            strSql.Append("HourlyPriceM=@HourlyPriceM,");
            strSql.Append("HourlyPrice=@HourlyPrice,");
            strSql.Append("SumPriceM=@SumPriceM,");
            strSql.Append("SumPrice=@SumPrice,");
            strSql.Append("Point=@Point,");
            strSql.Append("Remark=@Remark,");
            strSql.Append("CreateDate=@CreateDate,");
            strSql.Append("CreateUser=@CreateUser,");
            strSql.Append("DepotArea=@DepotArea,");
            strSql.Append("UsefulLifeType=@UsefulLifeType,");
            strSql.Append("UsefulLife=@UsefulLife,");
            strSql.Append("BaseProductPlace=@BaseProductPlace");
            strSql.Append(" where OrderDetailID=@OrderDetailID ");
            SqlParameter[] parameters = {
					new SqlParameter("@OrderID", SqlDbType.VarChar,10),
					new SqlParameter("@POrderDetailID", SqlDbType.VarChar,10),
					new SqlParameter("@PSaleDetailID", SqlDbType.VarChar,10),
					new SqlParameter("@RelaID", SqlDbType.VarChar,10),
					new SqlParameter("@ProductID", SqlDbType.VarChar,10),
					new SqlParameter("@ProductType", SqlDbType.VarChar,50),
					new SqlParameter("@ProductName", SqlDbType.VarChar,100),
					new SqlParameter("@ProductNo", SqlDbType.VarChar,100),
					new SqlParameter("@BatchNo", SqlDbType.VarChar,20),
					new SqlParameter("@PlnQuantity", SqlDbType.Decimal,9),
					new SqlParameter("@ShpQuantity", SqlDbType.Decimal,9),
					new SqlParameter("@ActQuantity", SqlDbType.Decimal,9),
					new SqlParameter("@BckQuantity", SqlDbType.Decimal,9),
					new SqlParameter("@UnitPriceM", SqlDbType.Decimal,9),
					new SqlParameter("@UnitPrice", SqlDbType.Decimal,9),
					new SqlParameter("@Discount", SqlDbType.Decimal,9),
					new SqlParameter("@ProductlPriceM", SqlDbType.Decimal,9),
					new SqlParameter("@ProductlPrice", SqlDbType.Decimal,9),
					new SqlParameter("@HourlyPriceM", SqlDbType.Decimal,9),
					new SqlParameter("@HourlyPrice", SqlDbType.Decimal,9),
					new SqlParameter("@SumPriceM", SqlDbType.Decimal,9),
					new SqlParameter("@SumPrice", SqlDbType.Decimal,9),
					new SqlParameter("@Point", SqlDbType.Decimal,9),
					new SqlParameter("@Remark", SqlDbType.VarChar,50),
					new SqlParameter("@CreateDate", SqlDbType.DateTime),
					new SqlParameter("@CreateUser", SqlDbType.VarChar,10),
					new SqlParameter("@DepotArea", SqlDbType.VarChar,20),
					new SqlParameter("@UsefulLifeType", SqlDbType.VarChar,10),
					new SqlParameter("@UsefulLife", SqlDbType.DateTime),
					new SqlParameter("@BaseProductPlace", SqlDbType.VarChar,100),
					new SqlParameter("@OrderDetailID", SqlDbType.VarChar,10)};
            parameters[0].Value = OrderID;
            parameters[1].Value = POrderDetailID;
            parameters[2].Value = PSaleDetailID;
            parameters[3].Value = RelaID;
            parameters[4].Value = ProductID;
            parameters[5].Value = ProductType;
            parameters[6].Value = ProductName;
            parameters[7].Value = ProductNo;
            parameters[8].Value = BatchNo;
            parameters[9].Value = PlnQuantity;
            parameters[10].Value = ShpQuantity;
            parameters[11].Value = ActQuantity;
            parameters[12].Value = BckQuantity;
            parameters[13].Value = UnitPriceM;
            parameters[14].Value = UnitPrice;
            parameters[15].Value = Discount;
            parameters[16].Value = ProductlPriceM;
            parameters[17].Value = ProductlPrice;
            parameters[18].Value = HourlyPriceM;
            parameters[19].Value = HourlyPrice;
            parameters[20].Value = SumPriceM;
            parameters[21].Value = SumPrice;
            parameters[22].Value = Point;
            parameters[23].Value = Remark;
            parameters[24].Value = CreateDate;
            parameters[25].Value = CreateUser;
            parameters[26].Value = DepotArea;
            parameters[27].Value = UsefulLifeType;
            parameters[28].Value = UsefulLife;
            parameters[29].Value = BaseProductPlace;
            parameters[30].Value = OrderDetailID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(string OrderDetailID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from [T_OrderDetail] ");
            strSql.Append(" where OrderDetailID=@OrderDetailID ");
            SqlParameter[] parameters = {
					new SqlParameter("@OrderDetailID", SqlDbType.VarChar,-1)};
            parameters[0].Value = OrderDetailID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public void GetModel(string OrderDetailID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select OrderDetailID,OrderID,POrderDetailID,PSaleDetailID,RelaID,ProductID,ProductType,ProductName,ProductNo,BatchNo,PlnQuantity,ShpQuantity,ActQuantity,BckQuantity,UnitPriceM,UnitPrice,Discount,ProductlPriceM,ProductlPrice,HourlyPriceM,HourlyPrice,SumPriceM,SumPrice,Point,Remark,CreateDate,CreateUser,DepotArea,UsefulLifeType,UsefulLife,BaseProductPlace ");
            strSql.Append(" FROM [T_OrderDetail] ");
            strSql.Append(" where OrderDetailID=@OrderDetailID ");
            SqlParameter[] parameters = {
					new SqlParameter("@OrderDetailID", SqlDbType.VarChar,-1)};
            parameters[0].Value = OrderDetailID;

            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["OrderDetailID"] != null)
                {
                    this.OrderDetailID = ds.Tables[0].Rows[0]["OrderDetailID"].ToString();
                }
                if (ds.Tables[0].Rows[0]["OrderID"] != null)
                {
                    this.OrderID = ds.Tables[0].Rows[0]["OrderID"].ToString();
                }
                if (ds.Tables[0].Rows[0]["POrderDetailID"] != null)
                {
                    this.POrderDetailID = ds.Tables[0].Rows[0]["POrderDetailID"].ToString();
                }
                if (ds.Tables[0].Rows[0]["PSaleDetailID"] != null)
                {
                    this.PSaleDetailID = ds.Tables[0].Rows[0]["PSaleDetailID"].ToString();
                }
                if (ds.Tables[0].Rows[0]["RelaID"] != null)
                {
                    this.RelaID = ds.Tables[0].Rows[0]["RelaID"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ProductID"] != null)
                {
                    this.ProductID = ds.Tables[0].Rows[0]["ProductID"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ProductType"] != null)
                {
                    this.ProductType = ds.Tables[0].Rows[0]["ProductType"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ProductName"] != null)
                {
                    this.ProductName = ds.Tables[0].Rows[0]["ProductName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ProductNo"] != null)
                {
                    this.ProductNo = ds.Tables[0].Rows[0]["ProductNo"].ToString();
                }
                if (ds.Tables[0].Rows[0]["BatchNo"] != null)
                {
                    this.BatchNo = ds.Tables[0].Rows[0]["BatchNo"].ToString();
                }
                if (ds.Tables[0].Rows[0]["PlnQuantity"] != null && ds.Tables[0].Rows[0]["PlnQuantity"].ToString() != "")
                {
                    this.PlnQuantity = decimal.Parse(ds.Tables[0].Rows[0]["PlnQuantity"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ShpQuantity"] != null && ds.Tables[0].Rows[0]["ShpQuantity"].ToString() != "")
                {
                    this.ShpQuantity = decimal.Parse(ds.Tables[0].Rows[0]["ShpQuantity"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ActQuantity"] != null && ds.Tables[0].Rows[0]["ActQuantity"].ToString() != "")
                {
                    this.ActQuantity = decimal.Parse(ds.Tables[0].Rows[0]["ActQuantity"].ToString());
                }
                if (ds.Tables[0].Rows[0]["BckQuantity"] != null && ds.Tables[0].Rows[0]["BckQuantity"].ToString() != "")
                {
                    this.BckQuantity = decimal.Parse(ds.Tables[0].Rows[0]["BckQuantity"].ToString());
                }
                if (ds.Tables[0].Rows[0]["UnitPriceM"] != null && ds.Tables[0].Rows[0]["UnitPriceM"].ToString() != "")
                {
                    this.UnitPriceM = decimal.Parse(ds.Tables[0].Rows[0]["UnitPriceM"].ToString());
                }
                if (ds.Tables[0].Rows[0]["UnitPrice"] != null && ds.Tables[0].Rows[0]["UnitPrice"].ToString() != "")
                {
                    this.UnitPrice = decimal.Parse(ds.Tables[0].Rows[0]["UnitPrice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Discount"] != null && ds.Tables[0].Rows[0]["Discount"].ToString() != "")
                {
                    this.Discount = decimal.Parse(ds.Tables[0].Rows[0]["Discount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ProductlPriceM"] != null && ds.Tables[0].Rows[0]["ProductlPriceM"].ToString() != "")
                {
                    this.ProductlPriceM = decimal.Parse(ds.Tables[0].Rows[0]["ProductlPriceM"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ProductlPrice"] != null && ds.Tables[0].Rows[0]["ProductlPrice"].ToString() != "")
                {
                    this.ProductlPrice = decimal.Parse(ds.Tables[0].Rows[0]["ProductlPrice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["HourlyPriceM"] != null && ds.Tables[0].Rows[0]["HourlyPriceM"].ToString() != "")
                {
                    this.HourlyPriceM = decimal.Parse(ds.Tables[0].Rows[0]["HourlyPriceM"].ToString());
                }
                if (ds.Tables[0].Rows[0]["HourlyPrice"] != null && ds.Tables[0].Rows[0]["HourlyPrice"].ToString() != "")
                {
                    this.HourlyPrice = decimal.Parse(ds.Tables[0].Rows[0]["HourlyPrice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SumPriceM"] != null && ds.Tables[0].Rows[0]["SumPriceM"].ToString() != "")
                {
                    this.SumPriceM = decimal.Parse(ds.Tables[0].Rows[0]["SumPriceM"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SumPrice"] != null && ds.Tables[0].Rows[0]["SumPrice"].ToString() != "")
                {
                    this.SumPrice = decimal.Parse(ds.Tables[0].Rows[0]["SumPrice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Point"] != null && ds.Tables[0].Rows[0]["Point"].ToString() != "")
                {
                    this.Point = decimal.Parse(ds.Tables[0].Rows[0]["Point"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Remark"] != null)
                {
                    this.Remark = ds.Tables[0].Rows[0]["Remark"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CreateDate"] != null && ds.Tables[0].Rows[0]["CreateDate"].ToString() != "")
                {
                    this.CreateDate = DateTime.Parse(ds.Tables[0].Rows[0]["CreateDate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CreateUser"] != null)
                {
                    this.CreateUser = ds.Tables[0].Rows[0]["CreateUser"].ToString();
                }
                if (ds.Tables[0].Rows[0]["DepotArea"] != null)
                {
                    this.DepotArea = ds.Tables[0].Rows[0]["DepotArea"].ToString();
                }
                if (ds.Tables[0].Rows[0]["UsefulLifeType"] != null)
                {
                    this.UsefulLifeType = ds.Tables[0].Rows[0]["UsefulLifeType"].ToString();
                }
                if (ds.Tables[0].Rows[0]["UsefulLife"] != null && ds.Tables[0].Rows[0]["UsefulLife"].ToString() != "")
                {
                    this.UsefulLife = DateTime.Parse(ds.Tables[0].Rows[0]["UsefulLife"].ToString());
                }
                if (ds.Tables[0].Rows[0]["BaseProductPlace"] != null)
                {
                    this.BaseProductPlace = ds.Tables[0].Rows[0]["BaseProductPlace"].ToString();
                }
            }
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * ");
            strSql.Append(" FROM [T_OrderDetail] ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }

        #endregion  Method
    }
}

